
const {ccclass, property} = cc._decorator;

/**
 * 手指动画
 */
@ccclass
export class HandItem_blxf extends cc.Component {

    @property({ type: cc.Node, tooltip: '手指动画节点' })
    handNode: cc.Node = null;


    @property({ tooltip: '传入参数' })
    _options: any = null;

    @property({ tooltip: 'tween动画' })
    _tween: cc.Tween = null;


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    protected onEnable(): void {
        this.onHandAnimation_blxf();
    }

    protected onDisable(): void {
        this.clearTween_blxf();
    }

    start () {
        
    }

    initData_blxf ( options: any ) {
        this._options = options;

        this.clearTween_blxf();
    }

    // update (dt) {}

    /** 手指动画 */
    onHandAnimation_blxf () {
        let _t1 = 0.4, _t2 = 0.4;
        let _scale1 = 0.85, _scale2 = 1;
        let _tween = cc.tween( this.handNode )
        .to(_t1, { scale: _scale1 })
        .to(_t2, { scale: _scale2 })

        this.handNode.scale = 1;
        this._tween = cc.tween( this.handNode ).repeatForever( _tween ).start();
    }

    clearTween_blxf () {
        this._tween && this._tween.stop();
        this._tween = null;
    }

}
